<!doctype html>
<html>
  <head>
    <script src="closure/goog/base.js"></script>
    <script src="./deps.js"></script>
    <script>
      goog.require('goog.events');
      goog.require('goog.testing.net.XhrIo');
      goog.require('camlistore.ServerConnection');
      goog.require('camlistore.BlobItemContainer');
    </script>
    <link rel="stylesheet" href="blob_item.css" type="text/css">
    <link rel="stylesheet" href="blob_item_container.css" type="text/css">
  </head>
  <body>
    <script>
      // Mock response from:
      //   http://127.0.0.1:3179/my-search/camli/search/recent?thumbnails=100
      var recentBlobResponse = {
        "recent": [
          {
            "blobref": "sha1-5660088af0aa0d4f2294088f41284002a1baaa29",
            "modtime": "2012-12-23T19:53:32Z",
            "owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4"
          },
          {
            "blobref": "sha1-3ced53f0a11115e98d6e40ca4558680f2768f23e",
            "modtime": "2012-12-23T19:19:37Z",
            "owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4"
          },
          {
            "blobref": "sha1-19236d4922116d03738f1c8c6d9f14debbab798b",
            "modtime": "2012-12-23T19:19:37Z",
            "owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4"
          }
        ],
        "sha1-19236d4922116d03738f1c8c6d9f14debbab798b": {
          "blobRef": "sha1-19236d4922116d03738f1c8c6d9f14debbab798b",
          "camliType": "permanode",
          "mimeType": "application/json; camliType=permanode",
          "permanode": {
            "attr": {
              "camliRoot": [
                "dev-pics-root"
              ],
              "title": [
                "Publish root node for dev-pics-root"
              ]
            }
          },
          "size": 562,
          "thumbnailHeight": 100,
          "thumbnailSrc": "node.png",
          "thumbnailWidth": 100
        },
        "sha1-3ced53f0a11115e98d6e40ca4558680f2768f23e": {
          "blobRef": "sha1-3ced53f0a11115e98d6e40ca4558680f2768f23e",
          "camliType": "permanode",
          "mimeType": "application/json; camliType=permanode",
          "permanode": {
            "attr": {
              "camliRoot": [
                "dev-blog-root"
              ],
              "title": [
                "Publish root node for dev-blog-root"
              ]
            }
          },
          "size": 562,
          "thumbnailHeight": 100,
          "thumbnailSrc": "node.png",
          "thumbnailWidth": 100
        },
        "sha1-5660088af0aa0d4f2294088f41284002a1baaa29": {
          "blobRef": "sha1-5660088af0aa0d4f2294088f41284002a1baaa29",
          "camliType": "permanode",
          "mimeType": "application/json; camliType=permanode",
          "permanode": {
            "attr": {
              "camliContent": [
                "sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725"
              ]
            }
          },
          "size": 556,
          "thumbnailHeight": 100,
          "thumbnailSrc": "thumbnail/sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725/leisure-suit-tony.gif?mw=100&mh=100",
          "thumbnailWidth": 100
        },
        "sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725": {
          "blobRef": "sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725",
          "camliType": "file",
          "file": {
            "size": 37741,
            "fileName": "leisure-suit-tony.gif",
            "mimeType": "image/gif"
          },
          "mimeType": "application/json; camliType=file",
          "size": 198
        }
      };

      var connection = new camlistore.ServerConnection(
        {
          'searchRoot': '/my/test/search'
        },
        goog.testing.net.XhrIo.send
      );

      var container = new camlistore.BlobItemContainer(connection);
      container.render(document.body);

      container.showRecent();

      var request = goog.testing.net.XhrIo.getSendInstances().pop();
      request.simulateResponse(200, JSON.stringify(recentBlobResponse));
    </script>
  </body>
</html>
